/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tnviet.proj.jna.report;

import java.util.Date;
import java.util.Locale;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
import tnviet.proj.jna.Program;
import tnviet.proj.jna.utilities.ResourceManager;

/**
 *
 * @author Administrator
 */
public class HourlyReportTableModel extends AbstractTableModel{

    Vector data;
    ResourceManager resourceManager = new ResourceManager(ReportPane.class, Program.locale);
    public HourlyReportTableModel(Vector data) {
        this.data = data;
    }

    public int getRowCount() {
        return data.size();
    }

    public int getColumnCount() {
        return 5;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        JNATraffic traffic = (JNATraffic)data.elementAt(rowIndex);
        switch(columnIndex){
            case 0:{
                Date date = new Date(traffic.getTime().getTime());
                return date;
            }
            case 1: return traffic.getIncoming();
            case 2: return traffic.getOutgoing();
            case 3: return traffic.getPacketsIn();
            case 4: return traffic.getPacketsOut();
            default: return null;
        }
    }

    @Override
    public String getColumnName(int column) {
        switch(column){
            case 0: return resourceManager.getString("dateOrTime");
            case 1: return resourceManager.getString("incoming");
            case 2: return resourceManager.getString("outgoing");
            case 3: return resourceManager.getString("inPackets");
            case 4: return resourceManager.getString("outPackets");
            default: return null;
        }
    }



    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }


}
